<?php

namespace App\Admin\Forms\Settings;

use App\Models\Setting;
use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

class BaseTabForm extends Form
{
	/**
	 * The form title.
	 *
	 * @var string
	 */
	public $title = '';
	
	/**
	 * Handle the form request.
	 *
	 * @param Request $request
	 *
	 */
	public function handle(Request $request)
	{
		foreach ($request->all() as $k => $v) {
			Setting::updateOrCreate(
				['name' => $k],
				['value' => $v]
			);
		}
		//      \Illuminate\Support\Facades\Cache::store('file')->forget('settings');
		Cache::store('file')->forever('settings', Setting::pluck('value', 'name'));
	}
}